<div class="sidebar" id="sidebar">
    <ul class="nav nav-list">
        <li>
            <a href="/admin/index.html">
                <i class="icon-dashboard"></i>
                <span class="menu-text">系统主页</span>
            </a>
        </li>
    </ul>
    <ul class="nav nav-list" id="menus">

    </ul>
</div>
<input type="hidden" id="current_url_value" />

<script type="text/javascript">
    function loadMenu(){
        loadGetServer('/manager/menu/getMenuList', {}, function (data) {
            var html = "";
            var list = data.list;
            for(var i = 0; i < list.length; i++){
                html+="<li><a url='"+list[i].url+"' href='javascript:void(0)' class='dropdown-toggle'><i class='"+list[i].icon+"'></i><span class='menu-text'> "+list[i].name+" </span></a>"
                if(list[i].hasOwnProperty("childlist")){
                    var childList = list[i].childlist;
                    html += "<ul class='submenu'>";
                    for(var j = 0; j < childList.length; j++){
                        html += "<li><a url='"+childList[j].url+"' href='javascript:void(0)' onclick='locationMenu(this)'><i class='"+childList[j].icon+"'></i>"+childList[j].name+"</a></li>"
                    }
                    html += "</ul>";
                }
            }
            $("#menus").html(html);
        });
    }

    function locationMenu(obj) {
        $("#menus li").removeClass("active");
        $(obj).parent().addClass("active");
        $("#current_url_value").val($(obj).attr("url"));
        $("#content").load("/admin"+$(obj).attr("url"));
    }
    loadMenu();
</script>
